home *** CD-ROM | disk | FTP | other *** search
- /* $VER: pstoedit.rexx 1.0 (15.1.96) Terje Pedersen */
-
- /* You need to do the following in order for it to work: */
-
- /* Copy pstoedit.pro to libx11: or change the libx11: reference */
- /* Make sure ghostscript is installed properly */
- /* Get a hold of rexxdossupport from aminet if you haven't already */
-
- /* note: This script it much slower than the unix script on large files */
-
- if ~show(l,'rexxdossupport.library') then
- if ~addlib('rexxdossupport.library',0,-30,2) then
- exit
-
- OPTIONS RESULTS
-
- Format ="fig"; Magnify=1
-
- REDEF="/textastext true def"
- DOESCAPE="/escapetext false def"
- DISPLAYOPTION="-dNODISPLAY"
- SUFFIX="fig"
-
- parse arg args
- if ReadArgs(args,'File/M,Format/K,Magnify/K,TextPoly/S,Display/S') then do
- FileName=""
- do i = 0 by 1 for file.count
- FileName = FileName file.i
- end
-
- if TextPoly then REDEF="/textastext false def"
- if Display then DISPLAYOPTION=""
-
- if Format = "fig" then SUFFIX="fig"
- if Format = "mif" then SUFFIX="mif"
- if Format = "tgif" then SUFFIX="tgif"
- if Format = "ps" then DOESCAPE="/escapetext true def"
-
- ADDRESS COMMAND
- 'copy' 'libx11:pstoedit.pro' 't:tmp1'
- ADDRESS REXX
- Open('temp','t:tmp1','a')
- Writeln('temp',REDEF)
- Writeln('temp',DOESCAPE)
- Close('temp')
-
- /* start ghostscript */
- ADDRESS COMMAND
- 'gs' '-dWRITESYSTEMDICT' DISPLAYOPTION '-q' 't:tmp1' FileName 'quit.ps < NIL: > t:tmp2'
-
- 'search' ' t:tmp2 SEARCH Error '
-
- if( RC = 0 ) then do
- say 'Ghostscript seems to have failed on file ' FileName
- say "Look into" t:tmp2 "for error messages from GhostScript"
- return -1
- end
- else do
- 'makeedit' '-m' Magnify '-f' Format ' -o t:tmp1 < t:tmp2'
- ADDRESS REXX
- if Format = "fig" then do
- Open('temp1','t:tmp1','r')
- Open('temp2','t:tmp2','w')
- Open('temp3','t:tmp3','w')
- do i = 0 by 1 for 5
- in = Readln('temp1')
- Writeln('temp2',in)
- end
- do while ~EOF('temp1')
- in = Readln('temp1')
- if subword(in,1,1) = "#color" then do
- Writeln('temp2',delword(in,1,1))
- end
- else do
- Writeln('temp3',in)
- end
- end
- Close('temp1')
- Close('temp2')
- Close('temp3')
- output=FileName
- n=index(FileName,".")
- if n>0 then output=delstr(FileName,n)
- output= output'.'SUFFIX
- ADDRESS COMMAND
- 'join' 't:tmp2 t:tmp3 to ' output
- 'delete' 't:tmp1 t:tmp2 t:tmp3 quiet'
- ADDRESS REXX
- say 'Output file written to' output
- end
- end
- return 0
- end
- else do
- say 'pstoedit File/M [Format/K] [Magnify/K] [TEXTPOLY] [DISPLAY]'
- end
-